package advance.app.service.impl;

import advance.app.dao.AppFileInfoMapper;
import advance.app.dao.NavigationMapper;
import advance.app.pojo.AppFileInfo;
import advance.app.pojo.Navigation;
import advance.app.pojo.SopFileInfo;
import advance.app.service.AppFileInfoService;
import advance.app.service.NavigationService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class AppFileInfoServiceImpl implements AppFileInfoService {

    @Autowired
    AppFileInfoMapper appFileInfoMapper;

    public int saveAppFileInfo(AppFileInfo info){
        AppFileInfo appInfo = new AppFileInfo();
        int rs = 0;
        if(null != info && info.getAppArea() != null && info.getVersion() != null){
            appInfo = appFileInfoMapper.getByVerAndTypeAndName(info.getAppArea(),
                    info.getFileType(), info.getFileName(), info.getVersion());
            if(null == appInfo){
                rs = appFileInfoMapper.saveAppFileInfo(info);
            }else{
                info.setId(appInfo.getId());
                rs = appFileInfoMapper.updateAppFileInfo(info);
            }
        }
        return rs;
    }

    @Override
    public int updateAppFileInfo(AppFileInfo info) {
        return 0;
    }

    public AppFileInfo getLatestInfoByType(String area,String fileType){
        return appFileInfoMapper.getLatestInfoByType(area,fileType);
    }

    public AppFileInfo getLatestInfoByMid(Integer id){
        return appFileInfoMapper.getLatestInfoByMid(id);
    }

    public List<String> getAllVerInfoByType(String area,String fileType){
        return appFileInfoMapper.getAllVerInfoByType(area,fileType);
    }

    @Override
    public AppFileInfo getByVerAndTypeAndName(String area, String fileType, String fileName, String version) {
        return null;
    }

    @Override
    public List<AppFileInfo> getNewByArea(String area, String exWise) {
        return appFileInfoMapper.getNewByArea(area,exWise);
    }
}
